//
//  RenHePartnerCell.m
//  BigToBig
//
//  Created by yi liu on 16/8/1.
//  Copyright © 2016年 cn.cloudtp. All rights reserved.
//

#import "RenHePartnerCell.h"
#import "HomeProjectMarkCell.h"

@implementation RenHePartnerCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
        
    }
    return self;
}

#pragma mark - 创建cell
- (void)createSubViews{
        
    //  头像
    self.headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, (kScreenWidth - 20)/6, (kScreenWidth - 20)/6)];
    self.headImageView.layer.cornerRadius = (kScreenWidth - 20)/12;
    [self addSubview:self.headImageView];
    
    self.headImageView.layer.masksToBounds = YES;
    
    // 姓名
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.headImageView.maxX + 10, self.headImageView.y, kScreenWidth - self.headImageView.maxX - 10, self.headImageView.height /3)];
    [self addSubview:self.nameLabel];
    self.nameLabel.textAlignment = NSTextAlignmentLeft;
    
    // 职位
    self.jobLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.nameLabel.maxX, self.nameLabel.y + self.nameLabel.height / 2, self.nameLabel.width, self.nameLabel.height / 2)];
    self.jobLabel.backgroundColor = [UIColor redColor];
    self.jobLabel.textColor = [UIColor lightGrayColor];
    self.jobLabel.textAlignment = NSTextAlignmentLeft;
    [self addSubview:self.jobLabel];
    
    // 描述
    self.describeLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.nameLabel.x, self.nameLabel.maxY + 5, kScreenWidth - self.headImageView.maxX- 20, self.nameLabel.height *2)];
    [self addSubview:self.describeLabel];
    self.describeLabel.numberOfLines = 0;
    self.describeLabel.font = [UIFont systemFontOfSize:12];
    self.describeLabel.textColor = [UIColor lightGrayColor];
    
    // 标签
    self.markLayout = [[UICollectionViewFlowLayout alloc]init];
    self.markLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.markLayout.itemSize = CGSizeMake(self.nameLabel.width / 5 , self.nameLabel.height);
    self.markLayout.sectionInset = UIEdgeInsetsMake(0, 5, 0, 5);
    
    self.markCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(self.describeLabel.x, self.describeLabel.maxY + 5, self.nameLabel.width, self.nameLabel.height)collectionViewLayout:self.markLayout];
    self.markCollectionView.delegate = self;
    self.markCollectionView.dataSource = self;
    self.markCollectionView.backgroundColor = [UIColor whiteColor];
    [self.markCollectionView registerClass:[HomeProjectMarkCell class] forCellWithReuseIdentifier:NSStringFromClass([HomeProjectMarkCell class])];
    [self addSubview:self.markCollectionView];
    
    
    // 合作项目图标
    self.projectImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth - 180, self.nameLabel.y, 20, 20)];
    self.projectImageView.image = [UIImage imageNamed:@"partner-project"];
    [self addSubview:self.projectImageView];
    
    // 合作项目人数
    self.projectLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth - 160, self.projectImageView.y,70 , 20)];
    self.projectLabel.font = [UIFont systemFontOfSize:11];
    self.projectLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:self.projectLabel];
    
    // 合作伙伴图标
    self.partnerImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth - 95, self.nameLabel.y, 20, 20)];
    self.partnerImageView.image = [UIImage imageNamed:@"partner-partner"];
    [self addSubview:self.partnerImageView];
    
    // 合作伙伴人数
    self.partnerLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenWidth - 73, self.partnerImageView.y, 65 , 20)];
    self.partnerLabel.font = [UIFont systemFontOfSize:10];
    self.partnerLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:self.partnerLabel];
    
    //线
    UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(10, self.markCollectionView.maxY + 10, kScreenWidth - 20, 0.5)];
    line.backgroundColor = [UIColor colorWithWhite:0.831 alpha:1.000];
    [self.contentView addSubview:line];
    
}

//- (void)layoutSubviews{
//    [super layoutSubviews];
//    self.headImageView.frame = CGRectMake(10, 10, (self.contentView.frame.size.height  -  30) , (self.contentView.frame.size.height  -  30));
//    self.headImageView.layer.cornerRadius = (self.contentView.frame.size.height  -  30)/2;
//    self.nameLabel.frame = CGRectMake(self.headImageView.maxX + 10, self.headImageView.y, kScreenWidth - self.headImageView.maxX - 10, self.headImageView.height /3);
//    self.jobLabel.frame = CGRectMake(self.nameLabel.maxX, self.nameLabel.y + self.nameLabel.height / 2, self.nameLabel.width, self.nameLabel.height / 2);
//    self.describeLabel.frame = CGRectMake(self.nameLabel.x, self.nameLabel.maxY , self.nameLabel.width, self.nameLabel.height);
//    
//    //
////    self.markCollectionView.frame = CGRectMake(self.describeLabel.x, self.describeLabel.maxY + 5, self.nameLabel.width, self.nameLabel.height);
//    
//    //
//    self.projectImageView.frame = CGRectMake(kScreenWidth /9 * 5, self.nameLabel.y, self.headImageView.width / 7 * 2, self.headImageView.width / 7 * 2);
//    self.projectLabel.frame = CGRectMake(self.projectImageView.maxX, self.projectImageView.y,kScreenWidth / 9 * 2 - self.projectImageView.width, self.projectImageView.height);
//    
//    self.partnerImageView.frame = CGRectMake(kScreenWidth / 9 * 7, self.nameLabel.y, self.projectImageView.width, self.projectImageView.height);
//    self.partnerLabel.frame = CGRectMake(self.partnerImageView.maxX, self.partnerImageView.y, self.projectLabel.width , self.projectLabel.height);
//    
//    
//    
//}


#pragma mark - markCollectionView 代理方法

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 4;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    HomeProjectMarkCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([HomeProjectMarkCell class]) forIndexPath:indexPath];
    cell.markContent = self.markArray[indexPath.row];
    
    return cell;
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
